﻿using AbstructFactory;
using ADManage.api.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using System.Web.UI;
using XF.Meeting.Api.Models;
using XF.Meeting.Entity.CommonEntity;
using XF.Meeting.Entity.dbEntity;
using XF.Meeting.Entity.DTO;
using XF.Meeting.Entity.Query;
using XF.Meeting.Entity.View;

namespace XF.Meeting.Api.Controllers
{
    public class UserController : BaseController
    {
        private readonly string secret = UCommonWork.Common.Commons.MD5DecodeString(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["secret"]));
        private readonly string ExpTime = UCommonWork.Common.Commons.MD5DecodeString(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["ExpTime"]));
        [HttpPost]
        [AllowAnonymous]
        public async Task <IHttpActionResult> Login([FromBody] UserLogin user)
        {
            if (ModelState.IsValid&&user!=null)
            {

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service= abs.CreateUserInfoInterface(user.userName, IPHelper.GetIPAddress);

                var result = await  service.Login(user.userName,user.passWord);
               
                TokenInfo token1 = new TokenInfo();
                if (result != null)
                {
                    string ParentOrgIdList = Newtonsoft.Json.JsonConvert.SerializeObject(result.ParentOrgIdList);
                    var jwtHelper = new JWTHelper();
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic.Add("userName", result.Account);
                    dic.Add("Name", result.AccountName);
                    dic.Add("IsAdmin", result.IsAdmin);
                    dic.Add("UserId", result.userId);
                    dic.Add("role", result.IsAdmin==3?"Admin":"User");
                    dic.Add("RegionalId", result.RegionalID);
                    dic.Add("RegionName", result.RegionalName);
                    dic.Add("OrgId", result.OrgId);
                    dic.Add("email", result.email);
                    dic.Add("ParentOrgIdList", ParentOrgIdList);
                    dic.Add("wxType", result.wxType);
                    var token = jwtHelper.Encode(dic, secret, Convert.ToInt32(ExpTime));

                    token1.success = true;
                    token1.Token = token;
                    token1.errmsg = "OK";
                    var res = new ResultBase<TokenInfo>()
                    {
                        data = token1,
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<TokenInfo>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = "用户名或密码验证不通过",
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
            }
            else {
                StringBuilder sb = new StringBuilder();
                foreach (KeyValuePair<string, ModelState> keyValue in ModelState)
                {
                    sb.Append( keyValue.Value.Errors.Select(e => e.ErrorMessage).ToString()+"<br />");
                }
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = sb.ToString(),
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }
        [HttpPost]
        [AllowAnonymous]
        public async Task<IHttpActionResult> LoginPhone([FromBody] ObjBase<UserLogin> user)
        {
          

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(user.obj.phone, IPHelper.GetIPAddress);

                var result = await service.Login(user.obj.phone);

                TokenInfo token1 = new TokenInfo();
                if (result != null)
                {

                    var jwtHelper = new JWTHelper();
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic.Add("userName", result.Account);
                    dic.Add("Name", result.AccountName);
                    dic.Add("IsAdmin", result.IsAdmin);
                    dic.Add("UserId", result.userId);
                    dic.Add("role", result.IsAdmin==3 ? "Admin" : "User");
                    dic.Add("RegionalId", result.RegionalID);
                  dic.Add("RegionName", result.RegionalName);
                  dic.Add("email", result.email);
                  dic.Add("OrgId", result.OrgId);
                dic.Add("wxType", result.wxType);
           
                var token = jwtHelper.Encode(dic, secret, Convert.ToInt32(ExpTime));

                    token1.success = true;
                    token1.Token = token;
                    token1.errmsg = "OK";
                    var res = new ResultBase<TokenInfo>()
                    {
                        data = token1,
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<TokenInfo>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = "请正确录入手机号！",
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
            }
        }
        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="pwd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> UpdatePassword([FromBody] ChangePwd pwd)
        {
            if (ModelState.IsValid && pwd != null)
            {
                var dic = User.Identity as ClaimsIdentity;
                var user = GetUser(dic);
                var service = abs.CreateUserInfoInterface(user.UserName, IPHelper.GetIPAddress); 
               // var service = bllFactory.GetUserManage(user.UserName, IPHelper.GetIPAddress);
                var result = await service.UpdatePassword(pwd.UserName, pwd.PassWord);
                var res = new ResultBase<string>()
                {
                    data = "true",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "用户名或密码验证不通过",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }

        }
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> AddUser([FromBody] ObjBase<UserInfo> user)
        {
            if (ModelState.IsValid && user != null)
            {

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

                var (result, strError) = await service.InsertUserInfo(user.obj);

            
                if (result)
                {
                    var res = new ResultBase<string>()
                    {
                        data = "创建成功",
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<string>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = strError,
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (KeyValuePair<string, ModelState> keyValue in ModelState)
                {
                    sb.Append(keyValue.Value.Errors.Select(e => e.ErrorMessage).ToString() + "<br />");
                }
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = sb.ToString(),
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }



        }
        /// <summary>
        /// 编辑用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> UpdateUser([FromBody] ObjBase<UserInfo> user)
        {
            if (ModelState.IsValid && user != null)
            {

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

                var (result, strError) = await service.UpdateUserInfo(user.obj);


                if (result)
                {
                    var res = new ResultBase<string>()
                    {
                        data = "修改成功",
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<string>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = strError,
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (KeyValuePair<string, ModelState> keyValue in ModelState)
                {
                    sb.Append(keyValue.Value.Errors.Select(e => e.ErrorMessage).ToString() + "<br />");
                }
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = sb.ToString(),
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }



        }
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> DeleteUserInfoByID([FromBody] ObjBase<UserInfo> user)
        {
           

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

                var result = await service.DeleteUserInfoByID(user.obj);


                if (result)
                {
                    var res = new ResultBase<string>()
                    {
                        data = "删除用户成功",
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<string>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = "删除用户失败",
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
        }
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> GetUserInfoList([FromBody] ObjBase<UserQuery> user)
        {
       

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

                var result = await service.GetUserInfoList(user.obj);


                if (result!=null)
                {
                    var res = new ResultBase<PageList<UserInfo>>()
                    {
                        data = result,
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<PageList<UserInfo>>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = "获取用户列表失败",
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
           



        }
        /// <summary>
        /// 根据ID获取用户信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> GetUserInfoByID([FromBody] ObjBase<UserQuery> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var result = await service.GetUserInfoByID(user.obj);


            if (result != null)
            {
                var res = new ResultBase<UserInfo>()
                {
                    data = result,
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<UserInfo>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "获取用户信息失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }




        }
        /// <summary>
        /// 根据区域获取用户信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> GetUserInfoListByRID([FromBody] ObjBase<UserQuery> user)
        {
            
                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

                var result = await service.GetUserInfoListByRID(user.obj);


                if (result != null)
                {
                    var res = new ResultBase<PageList<UserInfoForSearch>>()
                    {
                        data = result,
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<PageList<UserInfoForSearch>>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = "获取用户失败",
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
            



        }

        /// <summary>
        /// 根据区域获取用户信息(预约编辑回显)
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> GetUserInfoListByRIDForUpdate([FromBody] ObjBase<UserQuery> user)
        {

            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var result = await service.GetUserInfoListByRIDForUpdate(user.obj);


            if (result != null)
            {
                var res = new ResultBase<PageList<UserInfoForSearch>>()
                {
                    data = result,
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<PageList<UserInfoForSearch>>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "获取用户失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }




        }
        /// <summary>
        /// 根据key获取用户信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> GetUserInfoListByKey([FromBody] ObjBase<UserQuery> user)
        {
           

                var dics = User.Identity as ClaimsIdentity;
                var users = GetUser(dics);
                var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

                var result = await service.GetUserInfoListByKey(user.obj);


                if (result != null)
                {
                    var res = new ResultBase<PageList<UserInfoForSearch>>()
                    {
                        data = result,
                        success = true,
                        errormsg = ""
                    };
                    var data = new ObjBase<ResultBase<PageList<UserInfoForSearch>>>()
                    {
                        obj = res,
                        secret = "123"
                    };
                    return Content(HttpStatusCode.OK, data);
                }
                else
                {
                    var res = new ErrorBase()
                    {
                        data = "",
                        errmsg = "获取用户失败",
                        success = false
                    };
                    return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                    {
                        obj = res,
                        secret = "123"
                    }
                    );
                }
           



        }

        /// <summary>
        /// 修改用户区域
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> UpdateUserRegional([FromBody] ObjBase<UserInfo> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var (result, strError) = await service.UpdateUserRegional(user.obj);


            if (result)
            {
                var res = new ResultBase<string>()
                {
                    data = "修改用户区域成功",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "修改用户区域失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }

        /// <summary>
        /// 导入AD用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult>ADuserSYNC()
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var (bResult, strError) = await service.ADuserSYNC();


            if (bResult)
            {
                var res = new ResultBase<string>()
                {
                    data = "导入AD用户成功",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "导入AD用户失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }
        /// <summary>
        /// 获取白名单用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> GetWhiteList([FromBody] ObjBase<UserQuery> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var result = await service.GetWhiteList(user.obj);


            if (result != null)
            {
                var res = new ResultBase<PageList<WhiteList>>()
                {
                    data = result,
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<PageList<WhiteList>>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "获取白名单用户失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }




        }
        /// <summary>
        /// 新增白名单用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> InsertUserToWhiteList([FromBody] ObjBase<WhiteListUser> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var (result, strError) = await service.InsertUserToWhiteList(user.obj);


            if (result)
            {
                var res = new ResultBase<string>()
                {
                    data = "新增白名单用户成功",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "新增白名单用户失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }
        /// <summary>
        /// 修改白名单用户企业微信通知
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> UpdateToWhiteListUserMsg([FromBody] ObjBase<WhiteListUser> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var (result, strError) = await service.UpdateToWhiteListUserMsg(user.obj);


            if (result)
            {
                var res = new ResultBase<string>()
                {
                    data = "修改白名单用户企业微信通知成功",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "修改白名单用户企业微信通知失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }
        /// <summary>
        /// 修改白名单用户企业微信日程推送
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> UpdateToWhiteListUserSchedule([FromBody] ObjBase<WhiteListUser> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var (result, strError) = await service.UpdateToWhiteListUserSchedule(user.obj);


            if (result)
            {
                var res = new ResultBase<string>()
                {
                    data = "修改白名单用户企业微信日程推送成功",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "修改白名单用户企业微信日程推送失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }
        /// <summary>
        /// 删除白名单用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IHttpActionResult> DeleteToWhiteListUser([FromBody] ObjBase<WhiteListUser> user)
        {


            var dics = User.Identity as ClaimsIdentity;
            var users = GetUser(dics);
            var service = abs.CreateUserInfoInterface(users.UserName, IPHelper.GetIPAddress);

            var (result, strError) = await service.DeleteToWhiteListUser(user.obj);


            if (result)
            {
                var res = new ResultBase<string>()
                {
                    data = "删除白名单用户成功",
                    success = true,
                    errormsg = ""
                };
                var data = new ObjBase<ResultBase<string>>()
                {
                    obj = res,
                    secret = "123"
                };
                return Content(HttpStatusCode.OK, data);
            }
            else
            {
                var res = new ErrorBase()
                {
                    data = "",
                    errmsg = "删除白名单用户失败",
                    success = false
                };
                return Content(HttpStatusCode.OK, new ObjBase<ErrorBase>()
                {
                    obj = res,
                    secret = "123"
                }
                );
            }
        }
    }
}
